package com.ruoyi.system.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.equipment.EquipmentBook;
import com.ruoyi.system.domain.equipment.EquipmentByzx;
import com.ruoyi.system.domain.equipment.EquipmentService;
import com.ruoyi.system.domain.function.ProdOrder;
import com.ruoyi.system.mapper.EquipmentServiceMapper;
import com.ruoyi.system.mapper.ProdOrderMapper;
import com.ruoyi.system.mapper.equipment.EquipmentByzxMapper;
import com.ruoyi.system.service.TaskService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author 黄帝
 * @date 2023/4/18 13:39
 */
@Service
@RequiredArgsConstructor
public class TaskServiceImpl implements TaskService {

    private final EquipmentServiceMapper equipmentServiceMapper;
    private final EquipmentByzxMapper equipmentByzxMapper;

    @Override
    public void genEquipmentBy(Long id) {
        EquipmentService equipmentService = equipmentServiceMapper.selectById(id);
        if (equipmentService != null) {
            EquipmentByzx equipmentByzx = new EquipmentByzx();

            equipmentByzx.setCreateBy(SecurityUtils.getUsername());
            equipmentByzx.setCreateTime(new Date());
            equipmentByzx.setEquipmentName(equipmentService.getEquipment());
            equipmentByzx.setEquipmentType(equipmentService.getEquipmentType());
            equipmentByzxMapper.insert(equipmentByzx);
        }
    }
}
